#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "pythonlauncher.h"
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    // 注册QML类型
    qmlRegisterType<PythonLauncher>("PythonLauncher", 1, 0, "PythonLauncher");

    QQmlApplicationEngine engine;

    // 如果你想在QML中直接使用实例，也可以这样注册
    // BilibiliQRCodeGenerator qrGenerator;
    // engine.rootContext()->setContextProperty("qrGenerator", &qrGenerator);

    const QUrl url(QStringLiteral("test/Main.qml"));

    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
                         if (!obj && url == objUrl)
                             QCoreApplication::exit(-1);
                     }, Qt::QueuedConnection);

    engine.load(url);

    return app.exec();
}
